<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="90px"
    >
      <el-form-item label="时间范围">
        <el-date-picker
          v-model="dateRange"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="至"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          style="width: 240px"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="汇报人" prop="orderChildCode">
        <el-input v-model="queryParams.orderChildCode" placeholder="请输入汇报人" clearable />
      </el-form-item>
      <el-form-item label="汇报对象" prop="orderChildCode">
        <el-input v-model="queryParams.orderChildCode" placeholder="请输入汇报对象" clearable />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">导出</el-button>
      </el-col>

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange">
      <el-table-column label="汇报时间" align="center" prop="carrierCode" />
      <el-table-column label="汇报人" align="center" prop="carrierName" :show-overflow-tooltip="true" />
      <el-table-column label="汇报部门" align="center" prop="contacts" />
      <el-table-column label="汇报对象" align="center" prop="phone"></el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleDetails(scope.row)"
            v-hasPermi="['carrierPage:edit']"
          >查看</el-button>-->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
  
  <script>
export default {
  name: "carrierPage",
  dicts: ["supplier_status_audit", "tmstransport_carrier_class"],
  data() {
    return {
      openAudit: false,
      formData: {
        auditStatus: "1"
      },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 承运商表格数据
      configList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 日期范围
      dateRange: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderChildCode: undefined,
        contacts: undefined,
        carrierType: undefined
      }
    };
  },
  created() {
    // this.getList();
  },
  methods: {
    /** 查询承运商列表 */
    getList() {
      this.loading = true;
      listCarCarrier(this.addDateRange(this.queryParams, this.dateRange)).then(
        response => {
          this.configList = response.rows;
          this.total = response.total;
          this.loading = false;
          this.selectListCarCarrierFn();
        }
      );
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        carCarrierId: undefined,
        carrierName: undefined,
        carrierType: undefined,
        contacts: undefined,
        phone: "",
        remark: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {},
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.carCarrierId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },

    handleEffectStatusChange(row) {
      let text = row.effectStatus === "0" ? "启用" : "禁用";
      this.$modal
        .confirm("执行该操作吗")
        .then(function() {
          return carCarrierEffect(row.carCarrierId, row.effectStatus);
        })
        .then(() => {
          this.$modal.msgSuccess("操作成功");
        })
        .catch(function() {
          row.effectStatus = row.effectStatus === "0" ? "1" : "0";
        });
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/config/export",
        {
          ...this.queryParams
        },
        `config_${new Date().getTime()}.xlsx`
      );
    }
  }
};
</script>
  